package com.era.act.news;

import java.io.IOException;
import java.io.InputStream;
import java.net.URI;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.server.ServerHttpRequest;

import com.opensymphony.xwork2.ActionSupport;
import com.era.entity.NewsInfo;
import com.era.srv.NewsService;

public class NewsListById extends ActionSupport implements ServletRequestAware{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private int NewsId;
	private NewsInfo newsInfo;
	private NewsService newsSer;
	private HttpServletRequest request;
	public NewsService getNewsSer() {
		return newsSer;
	}
	public void setNewsSer(NewsService newsSer) {
		this.newsSer = newsSer;
	}
	public int getNewsId() {
		return NewsId;
	}
	public void setNewsId(int newsId) {
		NewsId = newsId;
	}
	public NewsInfo getNewsInfo() {
		return newsInfo;
	}
	public void setNewsInfo(NewsInfo newsInfo) {
		this.newsInfo = newsInfo;
	}
	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		System.out.println(NewsId);
		newsInfo = newsSer.findById(NewsId);
		System.out.println(newsInfo.getTitle() + newsInfo.getCandidator());
		request.getSession().setAttribute("newsInfo", newsInfo);
		return SUCCESS;
	}
	public void setServletRequest(HttpServletRequest arg0) {
		// TODO Auto-generated method stub
		this.request = arg0;
	}

	
	
}
